package com.juli.school.service.utils;

import java.util.ArrayList;
import java.util.List;
import com.juli.school.service.bo.CidBo;

/**
 * 实现批量导入入口(配合ConnectionClass、WorkThread、ConnectionPool)
 * 
 * @author wjp
 * @date 2017年8月2日
 *
 */
public class ImportEntry {
	
	private static ConnectionPool cpool = null;
	
	public static ConnectionPool getConnectionPool() {
		if (cpool == null) {
			cpool = new ConnectionPool();
			return cpool;
		} else
			return cpool;
	}
	
	/**
	 * 批量保存
	 * 
	 * @param cids
	 */
	public static void add(List<CidBo> cids) {
		List<Thread> list = new ArrayList<Thread>();
		// SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SS");
		// TimeZone t = sdf.getTimeZone();
		// t.setRawOffset(0);
		// sdf.setTimeZone(t);
		// Long startTime = System.currentTimeMillis();
		Thread g = new Thread(new WorkThread(cids)); // 进行保存
		g.start();
		list.add(g);
		try {
			for (Thread thread : list) {
				thread.join();// 堵塞作用，等待该线程终止
			}
		} catch (InterruptedException e) {
		}
		// Long endTime = System.currentTimeMillis();
		// System.out.println("总共用时: " + sdf.format(new Date(endTime -
		// startTime)));
	}
}
